//@flow

/**
 * 密码显示控制组件
 * 1，明文
 * 2，圆点
 */

import React, { Component } from 'react';
import { 
    View,
    Text,
 } from 'react-native';
import Icon from "react-native-vector-icons/Entypo";

type Props = {
    onChange:(isShow:boolean)=>{},//状态变化
}
type State = {
    show	:boolean,
    
}
export class PasswordDisplayControl extends Component <Props,State>{
    /**初始化state */
    state:State = {
        show:false
    }
    /**点击事件 */
    onClickIcon(){
        this.setState({show:!this.state.show},()=>{
            this.props.onChange(this.state.show)
        })
        
    }
    render(){
        let iconName :string = this.state.show ? 'eye':'eye-with-line'
        return <Icon name={iconName} 
                     size={20} 
                     color="white" 
                     onPress={()=>{
                         this.onClickIcon()
                     }}/>
         
    }
}